#include "stdafx.h"
#include "VectorRotation.h"

void VectorRotation::Rotate(int nArrList[], int nLength, int pos)
{
	Reverse(nArrList, 0, pos);
	Reverse(nArrList, pos+1, nLength - 1);
	Reverse(nArrList, 0, nLength - 1);
}

void VectorRotation::Reverse(int nArrList[], int nStart, int nEnd)
{
	int length = nEnd - nStart + 1;
	if(length > 0)
	{
		int tmp;
		while( (nEnd - nStart) > 0 )
		{
			tmp = nArrList[nStart];
			nArrList[nStart] = nArrList[nEnd];
			nArrList[nEnd] = tmp;
			++nStart;
			--nEnd;
		}
	}
}